var model = function() {}
const oneDayTime = 86400000
//获取指定时间周标识
model.getWeek = function(str){
    var nowTemp = new Date(str);//当前时间
    nowTemp.setHours(0,0,0,0)
    var c_time = nowTemp.getTime() ;//当前时间的毫秒时间
    var c_day = nowTemp.getDay()||7;//当前时间的星期几
    var m_time = c_time - (c_day-1)*oneDayTime;//当前周一的毫秒时间
    var monday = new Date(m_time);//设置周一时间对象
    var m_year = monday.getFullYear();
    var m_month = monday.getMonth()+1;
    var m_date = monday.getDate();
    return m_year+'-'+m_month+'-'+m_date
}
//获取往上周周标识
model.getBeforeWeek = function(value) {
    var nowTemp = new Date();//当前时间
    nowTemp.setHours(0,0,0,0)
    var c_time = nowTemp.getTime() ;//当前时间的毫秒时间
    var c_day = nowTemp.getDay()||7;//当前时间的星期几
    var m_time = c_time - (c_day-1+value*7)*oneDayTime;//当前周一的毫秒时间
    var monday = new Date(m_time);//设置周一时间对象
    var m_year = monday.getFullYear();
    var m_month = monday.getMonth()+1;
    var m_date = monday.getDate();
    return m_year+'-'+m_month+'-'+m_date
}
//获取指定时间月标识
model.getMonth = function(str){
    let d1 = new Date(str);
    return d1.getFullYear() + "-" + (d1.getMonth()+1);
}
//获取指定时间月标识
model.getBeforeMonth = function(value,time){
    var d1
    if(time)
        d1 = new Date(time)
    else
        d1 = new Date();
    d1.setMonth(d1.getMonth() - value,1)
    return d1.getFullYear() + "-" + (d1.getMonth()+1);
}
module.exports = model